package com.ruoyi.candidate_type.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.candidate_type.domain.TbCandidateType;
import com.ruoyi.candidate_type.service.ITbCandidateTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考生类型信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/candidate_type/candidate_type")
public class TbCandidateTypeController extends BaseController
{
    @Autowired
    private ITbCandidateTypeService tbCandidateTypeService;

    /**
     * 查询考生类型信息列表
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbCandidateType tbCandidateType)
    {
        startPage();
        List<TbCandidateType> list = tbCandidateTypeService.selectTbCandidateTypeList(tbCandidateType);
        return getDataTable(list);
    }

    /**
     * 导出考生类型信息列表
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:export')")
    @Log(title = "考生类型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCandidateType tbCandidateType)
    {
        List<TbCandidateType> list = tbCandidateTypeService.selectTbCandidateTypeList(tbCandidateType);
        ExcelUtil<TbCandidateType> util = new ExcelUtil<TbCandidateType>(TbCandidateType.class);
        util.exportExcel(response, list, "考生类型信息数据");
    }

    /**
     * 获取考生类型信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbCandidateTypeService.selectTbCandidateTypeById(id));
    }

    /**
     * 新增考生类型信息
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:add')")
    @Log(title = "考生类型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCandidateType tbCandidateType)
    {
        return toAjax(tbCandidateTypeService.insertTbCandidateType(tbCandidateType));
    }

    /**
     * 修改考生类型信息
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:edit')")
    @Log(title = "考生类型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCandidateType tbCandidateType)
    {
        return toAjax(tbCandidateTypeService.updateTbCandidateType(tbCandidateType));
    }

    /**
     * 删除考生类型信息
     */
    @PreAuthorize("@ss.hasPermi('candidate_type:candidate_type:remove')")
    @Log(title = "考生类型信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbCandidateTypeService.deleteTbCandidateTypeByIds(ids));
    }
}
